<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta charset="utf-8">
    <title>会员充值</title>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/favicon.ico"/>
    <link rel="bookmark" href="${pageContext.request.contextPath}/favicon.ico"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/webjars/layui/css/layui.css" media="all">
    <script type="application/javascript" src="${pageContext.request.contextPath}/webjars/layui/layui.js"
            charset="utf-8"></script>
    <script type="application/javascript" src="${pageContext.request.contextPath}/webjars/jquery/jquery.js"></script>
    <script type="application/javascript"
            src="${pageContext.request.contextPath}/private/js/loading/ajaxloading.js"></script>
</head>
<body>
<form id="form1" class="layui-form" action="">
    <table width="96%" align="center">
        <tr height="23">
            <td align="center">增加课时数:</td>
            <td align="left">
                <input type="hidden" id="userid" name="userid" value="${userid}"/>
                <input id="nums" name="nums" class="layui-input" type="text" placeholder="请输入要增加的课时数"
                       autocomplete="off" lay-verify="number">
            </td>
        </tr>
        <tr height="23">
            <td align="center">增加金额:</td>
            <td align="left">
                <input id="amount" name="amount" class="layui-input" type="text" placeholder="请输入充值金额"
                       autocomplete="off" lay-verify="number">
            </td>
        </tr>
        <tr height="23">
            <td align="center">充值月数(单位：月):</td>
            <td align="left">
                <input id="validmonths" name="validmonths" class="layui-input" type="text" placeholder="请输入充值月数"
                       autocomplete="off">
            </td>
        </tr>
        <tr height="23">
            <td align="center">备注:</td>
            <td align="left">
                <textarea name="comments" placeholder="请输入备注信息，可不填" class="layui-textarea"
                          lay-verify="comments"></textarea>
            </td>
        </tr>
        <tr height="23">
            <td align="center">充值类型:</td>
            <td align="left">
                <select id="rechargetype" name="rechargetype" lay-verify="rechargetype">
                    <option value="1">正常课时</option>
                    <option value="2">体验课时</option>
                </select>
            </td>
        </tr>

        <tr height="50">
            <td align="center">
                <button id="formsubmit" class="layui-btn" lay-submit lay-filter="saverechageinfo">保存</button>
            </td>
        </tr>
    </table>
</form>
</body>
<script type="application/javascript">
    var form;
    layui.use('form', function(){
        form = layui.form;

        //监听提交
        form.on('submit(saverechageinfo)', function(data){
            $.ajax({
                data : data.field,
                type : "POST",
                url : "${pageContext.request.contextPath}/eyas/rechargeinfo/saveRechageInfo",
                dataType : "json",
                success: function(data) {
                    layer.msg("保存成功,页面将在1秒后关闭");
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    },1000);
                },
                error:function(xdata){
                    console.log(xdata);
                    layer.msg(xdata.responseJSON.errormsg);
                }
            });
            return false;
        });
    });
</script>
</html>
